import { Spin } from 'antd'
import { connect } from 'umi';
import React, { useEffect } from 'react';
import LoadingIcon from '@/components/LoadingIcon'
import SaleWrapper from '../SaleWrapper'

const preSale = props => {
  const { dispatch, dealData, params, tab, tabKey, loading,stockMonitor } = props;

  useEffect(() => {
    if (tab === tabKey) {
      setTimeout(() => {
        dispatch({
          type: 'stockMonitor/fetchCommerBuildData',
          payload: 'deal'
        });
      }, 300)
    }
  }, [tabKey])

  return (
    <>
      <Spin spinning={loading} indicator={LoadingIcon} size="large">
        <SaleWrapper modelData={stockMonitor} dataRow={dealData} chartType="成交" params={params} dimension="new" unmountSign='1' nameSpace='stockMonitor'/>
      </Spin>
    </>
  );
}

export default connect(({ stockMonitor, loading }) => ({
  stockMonitor,
  dealData: stockMonitor.dealData,
  tabKey: stockMonitor.tabKey,
  loading: loading.models.stockMonitor,
}))(preSale);
